import request from './Request';

/**
 * @description 获取所有角色
 */
export const GetRoles = () => {
    return request.get("Rights/GetRoles");
}

/**
 * @description 添加角色
 * @param {String} name 要添加的角色名称
 */
export const AddRole = name => {
    return request.post('Rights/AddRole', JSON.stringify(name));
}

/**
 * @description 删除角色
 * @param {Number} id 要删除的角色ID
 */
export const DeleteRole = id => {
    return request.delete('Rights/DeleteRole', {
        params: {
            Id: id
        }
    });
}

/**
 * @description 修改角色
 * @param {Object} role 要修改的角色
 */
export const UpdateRole = role => {
    return request.put('Rights/UpdateRole', role);
}

/**
 * @description 获取所有菜单列表
 */
export const GetMenus = () => {
    return request.get('Rights/GetMenus');
}

/**
 * @description 获取当前医生菜单
 */
export const GetCurrentMenus = () => {
    return request.get('Rights/GetCurrentMenus');
}

/**
 * @description 根据角色ID获取权限
 * @param {Number} roleId 角色ID
 */
export const GetRights = roleId => {
    return request.get('Rights/GetRights', {
        params: { roleId }
    })
}

/**
 * @description 添加权限
 * @param {Number} roleId 角色ID
 * @param {Array} menuIds 菜单ID
 */
export const AddRights = (roleId, menuIds) => {
    return request.post('Rights/AddRights?roleId=' + roleId, menuIds);
}